import React from 'react'

const DatePicker = () => {
    const [pickerVisible, setPickerVisible] = useState(false)
  return (
    <div>
        <Form.Item
      noStyle
      shouldUpdate={(prevValues, curValues) =>
        prevValues.birthday !== curValues.birthday
      }
    >
      {({ getFieldValue, setFieldsValue }) => (
        <Form.Item
          name='birthday'
          label='带清除图标的时间选择器'
          trigger='onConfirm'
          arrow={
            getFieldValue('birthday') ? (
              <CloseCircleFill
                style={{
                  color: 'var(--adm-color-light)',
                  fontSize: 14,
                }}
                onClick={e => {
                  e.stopPropagation()
                  setFieldsValue({ birthday: null })
                }}
              />
            ) : (
              true
            )
          }
          onClick={() => {
            setPickerVisible(true)
          }}
        >
          <DatePicker
            visible={pickerVisible}
            onClose={() => {
              setPickerVisible(false)
            }}
          >
            {value =>
              value ? dayjs(value).format('YYYY-MM-DD') : '请选择日期'
            }
          </DatePicker>
        </Form.Item>
      )}
    </Form.Item>
    </div>
  )
}

export default DatePicker
